<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require_once APPLICATION_PATH.'/misc/additional.php';
class Application_Controllers_Admin_ActionEditPhoneController
{   public $Message="";
    //validation before registration
    public function prePhoneNumber($username,$form){
        $admin=new Application_Model_DbTable_Admin();
        $validatorChain = new Zend_Validate();
        $validatorChain2 = new Zend_Validate();
        $validatorChain->addValidator(
                         new Zend_Validate_StringLength(array('min' => 7)));

        $validatorChain2->addValidator(new Zend_Validate_Regex("/0([0-9]{1,3}-)?[0-9]{6,}/"));
        //Validation's logic begin here

        
       
        if(!$validatorChain2->isValid($form->getValue('newphone'))){
            //action
            $this->wrongMessage="No telephone yang anda masukan tidak valid";
            return false;
        }
       //check phone is it 10 digit
        if(!$validatorChain->isValid($form->getValue('newphone'))){
            //action
            $this->wrongMessage="nomor telephone yang anda masukan kurang ";
            return false;
        }
        if($form->getValue('newphone') == $form->getValue('phone')){
            $this->wrongMessage="No telp yang anda masukan sama";
            return false;
        }
         return true;
     
    }
    //action on registration
    public function onPhoneNumber($id,$form){

        
        $admins = new Application_Model_DbTable_Admin();
        $admins->updatePhoneNumber((int)$id, $form->getValue('newphone'));
       


    }
    public function postEdit($username,$phone){

    }
}
?>


